package JDKtest.java_lang_test.Hashmap;
import java.util.HashMap;

public class Main {
    HashMap<String, Integer>mymap = new HashMap<>();
    public static void main(String[] args)
    {
        Main m = new Main();
        m.mymap.put("a",1);
        m.mymap.put("b",2);
        m.mymap.put("c",3);


// Check map status

        System.out.println(m.mymap.get("a"));  // 输出: 1
        System.out.println(m.mymap.containsKey("a"));// true
        System.out.println(m.mymap.size());


// Operate map
        // remove kv
        m.mymap.remove("b");
        if (m.mymap.containsKey("b")) System.out.println("have contained b");
        if (m.mymap.isEmpty()) System.out.println("map is not empty");

        // updata kv
        m.mymap.replace("c",4);
        m.mymap.put("c",5);

        // clear map
        m.mymap.clear();
        if (m.mymap.isEmpty()) System.out.println("after clear , map is empty");


    }
}
